package com.atguigu.jeccache.service;

import com.alicp.jetcache.anno.*;
import com.atguigu.jeccache.entity.pojo.User;
import com.baomidou.mybatisplus.extension.service.IService;

/**
 * @author Jungle
 * @create 2024-12-21 11:04
 */
public interface UserService extends IService<User> {

    @Cached(name = "cache:user:", key = "#id", expire = 3600, cacheType = CacheType.BOTH, cacheNullValue = true)
    User getUserById(Long id);

    @CacheUpdate(name = "cache:user:", key = "#user.id", value = "#user")
    void updateUser(User user);

    @CacheInvalidate(name = "cache:user:", key = "#id")
    void deleteUser(long userId);



    @Cached(name = "user:token:", key = "#type", expire = 3600, cacheType = CacheType.REMOTE)
    @CacheRefresh(refresh = 1800, stopRefreshAfterLastAccess = 3600)
    @CachePenetrationProtect
    String getToken(Integer type);
}
